package Operation;

import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-06-02
 * Time: 21:47
 */
public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("3. 归还图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要归还的图书的名字：");
        String name = scanner.nextLine();
        int sz = bookList.getBookSize();

        for (int i = 0; i < sz; i++) {
            if(bookList.getBook(i).getName().equals(name)) {
                bookList.getBook(i).setState(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("书架上没有你要归还的图书。");
    }
}
